package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "maintenance_", schema = "crm")
public class Maintenance {
    private int maiId;
    private Date maiDate;
    private Integer maiConnectorClassify;
    private String maiFaultDescription;
    private String maiPoints;
    private Integer maiSchedule;
    private BigDecimal maiCost;
    private BigDecimal maiReceivable;
    private Integer maiExecuteState;
    private Date maiDeliverDate;
    private String maiRemarks;
    private String maiContactName;
    private String maiProductName;
    private String maiNo;
    private Collection<Action> actionsByMaiId;
    private Collection<Collectionrecord> collectionrecordsByMaiId;
    private Collection<InvoiceRecord> invoicerecordsByMaiId;
    private Employee employeeByEmpId;
    private Department departmentByDeptId;
    private Customer customerByCustomerId;
    private Collection<ProductDetail> productDetailsByMaiId;
    /*private Integer count;


    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }*/


    @Id
    @Column(name = "mai_id", nullable = false)
    public int getMaiId() {
        return maiId;
    }

    public void setMaiId(int maiId) {
        this.maiId = maiId;
    }



    @Basic
    @Column(name = "mai_date", nullable = true)
    public Date getMaiDate() {
        return maiDate;
    }

    public void setMaiDate(Date maiDate) {
        this.maiDate = maiDate;
    }

    @Basic
    @Column(name = "mai_connector_classify", nullable = true)
    public Integer getMaiConnectorClassify() {
        return maiConnectorClassify;
    }

    public void setMaiConnectorClassify(Integer maiConnectorClassify) {
        this.maiConnectorClassify = maiConnectorClassify;
    }

    @Basic
    @Column(name = "mai_fault_description", nullable = true, length = 255)
    public String getMaiFaultDescription() {
        return maiFaultDescription;
    }

    public void setMaiFaultDescription(String maiFaultDescription) {
        this.maiFaultDescription = maiFaultDescription;
    }

    @Basic
    @Column(name = "mai_points", nullable = true, length = 255)
    public String getMaiPoints() {
        return maiPoints;
    }

    public void setMaiPoints(String maiPoints) {
        this.maiPoints = maiPoints;
    }

    @Basic
    @Column(name = "mai_schedule", nullable = true)
    public Integer getMaiSchedule() {
        return maiSchedule;
    }

    public void setMaiSchedule(Integer maiSchedule) {
        this.maiSchedule = maiSchedule;
    }

    @Basic
    @Column(name = "mai_cost", nullable = true, precision = 2)
    public BigDecimal getMaiCost() {
        return maiCost;
    }

    public void setMaiCost(BigDecimal maiCost) {
        this.maiCost = maiCost;
    }

    @Basic
    @Column(name = "mai_receivable", nullable = true, precision = 2)
    public BigDecimal getMaiReceivable() {
        return maiReceivable;
    }

    public void setMaiReceivable(BigDecimal maiReceivable) {
        this.maiReceivable = maiReceivable;
    }

    @Basic
    @Column(name = "mai_execute_state", nullable = true)
    public Integer getMaiExecuteState() {
        return maiExecuteState;
    }

    public void setMaiExecuteState(Integer maiExecuteState) {
        this.maiExecuteState = maiExecuteState;
    }

    @Basic
    @Column(name = "mai_deliver_date", nullable = true)
    public Date getMaiDeliverDate() {
        return maiDeliverDate;
    }

    public void setMaiDeliverDate(Date maiDeliverDate) {
        this.maiDeliverDate = maiDeliverDate;
    }

    @Basic
    @Column(name = "mai_remarks", nullable = true, length = 255)
    public String getMaiRemarks() {
        return maiRemarks;
    }

    public void setMaiRemarks(String maiRemarks) {
        this.maiRemarks = maiRemarks;
    }

    @Basic
    @Column(name = "mai_contact_name", nullable = true, length = 255)
    public String getMaiContactName() {
        return maiContactName;
    }

    public void setMaiContactName(String maiContactName) {
        this.maiContactName = maiContactName;
    }

    @Basic
    @Column(name = "mai_product_name", nullable = true, length = 255)
    public String getMaiProductName() {
        return maiProductName;
    }

    public void setMaiProductName(String maiProductName) {
        this.maiProductName = maiProductName;
    }

    @Basic
    @Column(name = "mai_no", nullable = true, length = 255)
    public String getMaiNo() {
        return maiNo;
    }

    public void setMaiNo(String maiNo) {
        this.maiNo = maiNo;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Maintenance that = (Maintenance) o;
        return maiId == that.maiId &&
                Objects.equals(maiDate, that.maiDate) &&
                Objects.equals(maiConnectorClassify, that.maiConnectorClassify) &&
                Objects.equals(maiFaultDescription, that.maiFaultDescription) &&
                Objects.equals(maiPoints, that.maiPoints) &&
                Objects.equals(maiSchedule, that.maiSchedule) &&
                Objects.equals(maiCost, that.maiCost) &&
                Objects.equals(maiReceivable, that.maiReceivable) &&
                Objects.equals(maiExecuteState, that.maiExecuteState) &&
                Objects.equals(maiDeliverDate, that.maiDeliverDate) &&
                Objects.equals(maiRemarks, that.maiRemarks) &&
                Objects.equals(maiContactName, that.maiContactName) &&
                Objects.equals(maiProductName, that.maiProductName) &&
                Objects.equals(maiNo, that.maiNo);
    }

    @Override
    public int hashCode() {
        return Objects.hash(maiId, maiDate, maiConnectorClassify, maiFaultDescription, maiPoints, maiSchedule, maiCost, maiReceivable, maiExecuteState, maiDeliverDate, maiRemarks, maiContactName, maiProductName, maiNo);
    }

    @OneToMany(mappedBy = "maintenanceByMaiId")
    public Collection<Action> getActionsByMaiId() {
        return actionsByMaiId;
    }

    public void setActionsByMaiId(Collection<Action> actionsByMaiId) {
        this.actionsByMaiId = actionsByMaiId;
    }

    @OneToMany(mappedBy = "maintenanceByMaiId")
    public Collection<Collectionrecord> getCollectionrecordsByMaiId() {
        return collectionrecordsByMaiId;
    }

    public void setCollectionrecordsByMaiId(Collection<Collectionrecord> collectionrecordsByMaiId) {
        this.collectionrecordsByMaiId = collectionrecordsByMaiId;
    }

    @OneToMany(mappedBy = "maintenanceByMaiId")
    public Collection<InvoiceRecord> getInvoicerecordsByMaiId() {
        return invoicerecordsByMaiId;
    }

    public void setInvoicerecordsByMaiId(Collection<InvoiceRecord> invoicerecordsByMaiId) {
        this.invoicerecordsByMaiId = invoicerecordsByMaiId;
    }

    @ManyToOne
    @JoinColumn(name = "emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByEmpId() {
        return employeeByEmpId;
    }

    public void setEmployeeByEmpId(Employee employeeByEmpId) {
        this.employeeByEmpId = employeeByEmpId;
    }

    @ManyToOne
    @JoinColumn(name = "dept_id", referencedColumnName = "dept_id")
    public Department getDepartmentByDeptId() {
        return departmentByDeptId;
    }

    public void setDepartmentByDeptId(Department departmentByDeptId) {
        this.departmentByDeptId = departmentByDeptId;
    }

    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }

    @OneToMany(mappedBy = "maintenanceByMaiId")
    public Collection<ProductDetail> getProductDetailsByMaiId() {
        return productDetailsByMaiId;
    }

    public void setProductDetailsByMaiId(Collection<ProductDetail> productDetailsByMaiId) {
        this.productDetailsByMaiId = productDetailsByMaiId;
    }
}
